//
//  UIImage+ZXImage.m
//  XiMaFM
//
//  Created by fanzhuxian on 2017/9/8.
//  Copyright © 2017年 hcios. All rights reserved.
//

#import "UIImage+ZXImage.h"

@implementation UIImage (ZXImage)

- (instancetype)zx_circleImage {
 
    //开启图形上下文
    UIGraphicsBeginImageContextWithOptions(self.size, NO, 0);
    //描述裁剪区域
    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, self.size.width, self.size.width)];
    //设置裁剪区域
    [path addClip];
    //画图形
    [self drawAtPoint:CGPointZero];
    //取出图片
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    //关闭图形上下文
    UIGraphicsEndImageContext();
    
    return image;
    
}

@end
